<?php

function getChild($data,$pid=0){
    $res = array();
    
    foreach ($data as $v){
        if ($v['pid'] == $pid){
            $res[] = $v;
            $res = array_merge($res,getChild($data,$v['id']));
        }
    }
    return $res;
}

/**
 * 实现栏目无限分类
 * @param array $data 需要分类的数据
 * @param number $pid
 * @return array
 */
function threeData($data,$pid=0,$C_count=0){
    $res = array();
    
    foreach ($data as $v){
        if ($v['pid'] == $pid){
            $v['C_count'] = $C_count+1;
            $res[] = $v;
            
            $res = array_merge($res,threeData($data,$v['id'],$v['C_count']));
        }
    }
    return $res;
}